package com.hzit.manager.controller;

import com.hzit.util.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
@RefreshScope           // 添加此注解，可以得到最新修改后的配置信息
public class UserController {
	@Value("${hzit.user.username}")
	private String username;
	@Value("${hzit.student.sname}")
	private String sname;
	@Value("${hzit.student.addr}")
	private String addr;
	@GetMapping("/config")
	public R readConfig(){
		return R.ok(username);
	}

	//读取共享配置
	@GetMapping("/readcommonconfig")
	public R readCommonConfig(){
		Map<Object, Object> map = new HashMap<>();
		map.put("sname",sname);
		map.put("addr",addr);
		return R.ok(map);
	}
}
